package com.example.spring_boot_demo.controller;

import com.example.spring_boot_demo.utils.AjaxResult;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServlet;
import java.util.ArrayList;
import java.util.List;

/**
 * <P> @Author: SongKeCheng
 * <P> Type: Class
 * <P> Description:
 * <P> Date: 2024/12/18:8:28
 */

@SuppressWarnings({"unchecked", ""})
@Controller
@RequestMapping("/test")
public class TestController {

    private static final Logger log = LoggerFactory.getLogger(DemoController.class);

    @Autowired
    private TestController testController;


    @ResponseBody
    @RequestMapping(value = "/start")
    public String startTest() {
        return "success";
    }

    @RequestMapping("/getBean")
    @ResponseBody
    public String getBean(){
        log.info("{}",testController);
        return "this is response";
    }

    @GetMapping("/findAllUser")
    @ResponseBody
    public AjaxResult findAllUser(String name){
        List<ElUser> list = new ArrayList<>();
        for (int i = 0; i <5; i++) {
            ElUser elUser = new ElUser();
            elUser.setName("小虎-"+ i);
            elUser.setSex(i);
            list.add(elUser);
        }
        return AjaxResult.success(list);
    }


    @Data
    static class ElUser{

        String name;
        String address;
        Integer sex;
    }
}
